#include<bits/stdc++.h>
using namespace std;
#define int long long
#define getchar() (p1 == p2 && (p2 = (p1 = buf1) + fread(buf1, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf1[1 << 23], *p1 = buf1, *p2 = buf1, ubuf[1 << 23], *u = ubuf;
namespace IO
{
	template<typename T>
	void read(T &_x){_x=0;int _f=1;char ch=getchar();while(!isdigit(ch)) _f=(ch=='-'?-1:_f),ch=getchar();while(isdigit(ch)) _x=_x*10+(ch^48),ch=getchar();_x*=_f;}
	template<typename T,typename... Args>
	void read(T &_x,Args&...others){Read(_x);Read(others...);}
	const int BUF=20000000;char buf[BUF],to,stk[32];int plen;
	#define pc(x) buf[plen++]=x
	#define flush(); fwrite(buf,1,plen,stdout),plen=0;
	template<typename T>inline void print(T x){if(!x){pc(48);return;}if(x<0) x=-x,pc('-');for(;x;x/=10) stk[++to]=48+x%10;while(to) pc(stk[to--]);}
}
using namespace IO;
const int N = 5e5+10;
int n,dis[N],v[N],ans,x,y,X,Y,len,len1,S,L,R,o,o1;
map<pair<int,int>,int>mp;
struct w
{
	int x,y;
}a[N];
inline bool cmp(w x,w y){ return x.x > y.x; }
vector<int>v1[N];
queue<int>p;
inline void bfs()
{
	while(!p.empty())
	{
		x = p.front(); p.pop();
		for(int j = 0;j < v1[x].size();j++)
			if(!v[v1[x][j]])
			{
				v[v1[x][j]] = 1,dis[v1[x][j]] = dis[x]+1;
				p.push(v1[x][j]);
			}
	}
}
signed main()
{
	freopen("game.in","r",stdin);
	freopen("game.out","w",stdout);
	read(n);
	for(int i = 1;i <= n;i++) read(a[i].x),read(a[i].y);
	if(n <= 0)
	{
		for(int i = 1;i <= n;i++)
			for(int j = i+1;j <= n;j++)
				if(abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y) == 1)
				{
					v1[i].push_back(j);
					v1[j].push_back(i);
				}
		for(int i = 1;i <= n;i++)
		{
			for(int j = 1;j <= n;j++) v[j] = 0;
			dis[i] = 0,v[i] = 1; p.push(i); bfs();
			for(int j = i+1;j <= n;j++) ans += dis[j];
		}
		print(ans); flush();
		return 0;
	} x = y = 1e14;
	for(int i = 1;i <= n;i++) 
	{
		x = min(x,a[i].x),y = min(y,a[i].y);
		X = max(X,a[i].x),Y = max(Y,a[i].y);
	} len = X-x+1,len1 = Y-y+1;
	for(int i = 1;i <= len;i++)
	{
		for(int j = 1;j <= len1;j++)
		{
			ans += (i*i-(1+i)*i/2)*len1+(j*j-(1+j)*j/2)*len;
			ans += ((i+len)*(len-i+1)/2-i*(len-i+1))*len1+((j+len1)*(len1-j+1)/2-j*(len1-j+1))*len;
		}
	}
	print(ans/2); flush();
	return 0;
}

